<script>
document.addEventListener('DOMContentLoaded', function() {

  let elem = document.getElementById('coords-show-mark');

  // no elem in ebook (pdf/epub) mode
  if (elem) {
    elem.onclick = function() {

      function createMessageUnder(elem, text) {
        let coords = elem.getBoundingClientRect();
        let message = document.createElement('div');
        message.style.cssText = "position:fixed; color: red";

        message.style.left = coords.left + "px";
        message.style.top = coords.bottom + "px";

        message.innerHTML = text;

        return message;
      }

      let message = createMessageUnder(elem, 'Hello, world!');
      document.body.append(message);
      setTimeout(() => message.remove(), 5000);
    }
  }

});

</script>
